import Vue from 'vue'
import VueRouter from 'vue-router'


Vue.use(VueRouter)

const routes = [
  {
    path: '/login',
    name: 'login',
    // 路由懒加载的写法：访问到/login的网页才下载login组件的相关代码，可以提高性能
    component: ()=> import('@/views/Login')
  },
  {
    path: '/',
    component: () => import('@/views/layout'),
    redirect: '/home',
    children: [
      {
        path: 'home',
        name: 'home',
        component : () => import('@/views/home')
      },
      {
        path: 'qa',
        name: 'qa',
        component: () => import('@/views/qa')
      },
      {
        path: 'my',
        name: 'my',
        component: () => import('@/views/my')
      },
    ]
  },
  {
    path: '/article/:id',
    name: 'article',
    component: () => import('@/views/article'),
    props: true,
  }
]

const router = new VueRouter({
  routes
})

export default router
